<template>
  <div>
    <el-form ref="ruleForm" label-width="80px" :model="formItem" :rules="rules">
      <el-form-item label="账号" prop="mobile">
        <el-input v-model="formItem.mobile" />
      </el-form-item>
      <el-form-item label="密码" prop="password">
        <el-input v-model="formItem.password" />
      </el-form-item>
      <el-form-item label="再次输入密码" prop="inPassword">
        <el-input v-model="formItem.inPassword" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
// import { getProfile } from '@/api/user'
export default {
  data() {
    const validator = (rule, value, callback) => {
      console.log(this.formItem)
      if (value === this.formItem.password) {
        callback()
      } else {
        callback(new Error('输入错误了o'))
      }
    }
    return {
      formItem: {
        mobile: '',
        password: '',
        inPassword: ''
      },
      rules: {
        mobile: [
          { required: true, message: '请输入账号', trigger: 'blur' }
        ],
        password: [
          { required: true, message: '请输入密码', trigger: 'blur' }
        ],
        inPassword: [
          { validator: validator, trigger: 'blur' }
        ]
      }
    }
  },
  async created() {
    await this.$store.dispatch('user/getProfile')
  }

}
</script>

<style>

</style>
